package com.mysoft.gfyx.common.rpc.openapi.impl;

import com.mysoft.gfyx.common.rpc.openapi.OpenapiClientFactoryService;
import com.mysoft.gfyx.common.rpc.openapi.OpenapiClientService;
import feign.Feign;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class OpenapiClientFactoryServiceImpl implements OpenapiClientFactoryService {

    @Value("${openapi.host}")
    private String host;

    public OpenapiClientService getOpenapiService() {
        OpenapiClientService service = Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .target(OpenapiClientService.class, host);

        return service;
    }
}
